package com.neusoft.work.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.work.dto.OutRegistrationDto;
import com.neusoft.work.po.OutRegistration;
import com.neusoft.work.po.PageResponseBean;
import com.neusoft.work.po.ResponseBean;
import com.neusoft.work.service.OutRegistrationService;


@RestController
@RequestMapping("/OutRegistrationController")
public class OutRegistrationController {

    @Autowired
    private OutRegistrationService service;

    @RequestMapping("/queryAll")
    public PageResponseBean<List<OutRegistrationDto>> queryAll(String name,Long cur, Long number) {
    	return service.queryAll(name, cur, number);
    }

    @RequestMapping("/add")
    public ResponseBean<Integer> add(OutRegistration record) {
    	return service.add(record);
    }
    
    @RequestMapping("/update")
    public ResponseBean<Integer> update(OutRegistration record) {
    	return service.update(record);
    }

    @RequestMapping("/delete")
    public ResponseBean<Integer> delete(Integer id) {
    	return service.delete(id);
    }
    
    @PostMapping("/approve")
    public ResponseBean<Integer> approve(Integer id,
                                      Integer approveStatus,
                                      Integer operatorUserId) {
        return service.approve(id, approveStatus, operatorUserId);
    }
    
    @PostMapping("/search")
    public PageResponseBean<List<OutRegistrationDto>> search(
        @RequestParam Integer healthManagerId,
        @RequestParam(required = false) String clientName,
        @RequestParam Long cur,
        @RequestParam Long number) {
        return service.searchRegistration(healthManagerId, clientName, cur, number);
    }

    @PostMapping("/revoke")
    public ResponseBean<Integer> revoke(
        @RequestParam Integer id) {
        return service.revoke(id);
    }

    @PostMapping("/registerReturn")
    public ResponseBean<Integer> registerReturn(
        @RequestParam Integer id,
        @RequestParam String actualReturnTime) {
        return service.registerReturn(id, actualReturnTime);
    }

}
